package com.itrident.matcher;

import com.intellij.codeInsight.completion.PrefixMatcher;
import org.jetbrains.annotations.NotNull;

/**
 * @author cxx
 * @create 2020-12-28 22:57
 **/
public class UnderlinePrefixMatcher extends PrefixMatcher {

    protected UnderlinePrefixMatcher(String prefix) {
        super (prefix);
    }

    @Override
    public boolean prefixMatches(@NotNull String pre) {
        if (this.myPrefix == null) {
            return false;
        }
        return this.myPrefix.equals ("") || this.myPrefix.startsWith ("@") ;
    }

    @NotNull
    @Override
    public PrefixMatcher cloneWithPrefix(@NotNull String s) {
        return this;
    }

    public static PrefixMatcher create(String prefix){
        return new UnderlinePrefixMatcher (prefix);
    }

}
